﻿using Furion.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using Thor.Core;

namespace Thor.Application
{
    public class UserService: IUserService, ITransient
    {
        private readonly ISqlSugarRepository<User> _userRepository;
        private readonly IRoleService _roleService;

        public UserService(ISqlSugarRepository<User> userRepository, IRoleService roleService)
        {
            _userRepository = userRepository;
            _roleService = roleService;
        }

        [Transactional]
        public async Task add(User entity)
        {
            await _userRepository.InsertAsync(entity);
            await _roleService.add(new Role { Code = 1, Name = "fhl" });
            //throw new Exception("测试事务");
        }

    }
}
